package com.ts.geo.controller;


import com.ts.geo.services.GeoServices;
import com.ts.geo.vo.AddLocation;
import com.ts.geo.vo.UserLocation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.geo.GeoResults;
import org.springframework.data.redis.connection.RedisGeoCommands;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/geo")
@Slf4j
public class GeoController {
    @Autowired
    private GeoServices geoServices;
    @PostMapping("/addLocation")
    public void addLocation(@RequestBody AddLocation addLocation) {
        log.debug(addLocation.toString());
        geoServices.addLocation(addLocation);
    }

    @PostMapping ("/nearby")
    public GeoResults<RedisGeoCommands.GeoLocation<String>> getNearbyUsers(@RequestBody UserLocation location) {
        return geoServices.getNearbyUsers(location);
    }

}
